package com.ah.shanxi_demo.controller.web;

import com.ah.shanxi_demo.param.input.ReceiptPO;
import com.ah.shanxi_demo.param.result.SXResult;
import com.ah.shanxi_demo.service.IReceiptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zt 2020/8/14
 */

@RestController
@Api(value = "陕西高速", description = "陕西高速-工单回执服务")
@RequestMapping(value = "/api/v1/shanxi/order/")
public class ApiOrderOperateController {

    private static final Logger log = LoggerFactory.getLogger(ApiOrderOperateController.class);

    @Autowired
    private IReceiptService receiptService;


    @ApiOperation(value = "工单回执故障", notes = "工单回执故障")
    @RequestMapping(value = "malfunction", method = RequestMethod.POST)
    public SXResult<Boolean> malfunction(@RequestBody ReceiptPO receiptPO) {

        try {
            Boolean receiptSimulation = receiptService.receiptSimulation(receiptPO);
            return SXResult.instance(receiptSimulation);
        } catch (Throwable e) {
            log.error("ApiOrderOperateController 【malfunction】" + e.getMessage());
        }
        return SXResult.instance();
    }

    @ApiOperation(value = "工单预警处理", notes = "工单预警处理")
    @RequestMapping(value = "warn", method = RequestMethod.POST)
    public SXResult<Boolean> warn(@RequestBody ReceiptPO receiptPO) {
        try {
            return SXResult.instance(receiptService.receiptSimulation(receiptPO));
        } catch (Throwable e) {
            log.error("ApiOrderOperateController 【warn】" + e.getMessage());
        }
        return SXResult.instance();
    }


    @ApiOperation(value = "工单安全整改", notes = "工单安全整改")
    @RequestMapping(value = "safetyRectification", method = RequestMethod.POST)
    public SXResult<Boolean> safetyRectification(@RequestBody ReceiptPO receiptPO) {
        try {
            return SXResult.instance(receiptService.receiptSimulation(receiptPO));
        } catch (Throwable e) {
            log.error("ApiOrderOperateController 【safetyRectification】" + e.getMessage());
        }
        return SXResult.instance();
    }

    @ApiOperation(value = "工单安全资讯", notes = "工单安全资讯")
    @RequestMapping(value = "news", method = RequestMethod.POST)
    public SXResult<Boolean> news(@RequestBody ReceiptPO receiptPO) {
        try {
            return SXResult.instance(receiptService.receiptSimulation(receiptPO));
        } catch (Throwable e) {
            log.error("ApiOrderOperateController 【news】" + e.getMessage());
        }
        return SXResult.instance();
    }
}
